exports.settingSiteConfig = function(req,res){

    var bodyParams = req.routeInfo.bodyParams;

    var isExistConfig = false;

    //查看是否有配置
    function isExistSetting(cb){

        R.SEND_HTTP(
            req,
            res,
            {
                url    : CORE_APIConfig.coreAPI.cmsSiteConfigSearch.Request_Api_Url,
                method : 'POST'
            },
            function (data) { 

                if(data.result.data.length > 0){
                    isExistConfig = true;
                }

                cb();
                
            }
        )

        

    }

    //无配置进行添加，有配置进行更新
    function addOrUpdateSetting(cb){

        //更新站点配置
        if(isExistConfig){

            if(bodyParams.csc_id == undefined){
                return RES.errorResponse(res,'抱歉，缺少更新所需参数csc_id');
            }

            //添加更新所需参数
            bodyParams.update_where = "csc_id";

            R.SEND_HTTP(
                req,
                res,
                {
                    url    : CORE_APIConfig.coreAPI.cmsSiteConfigUpdate.Request_Api_Url,
                    method : 'POST',
                    data   : bodyParams
                },
                function (data) { 
    
                    cb();
                    
                }
            )

        //新增站点配置     
        }else{

            console.log("add config");

            R.SEND_HTTP(
                req,
                res,
                {
                    url    : CORE_APIConfig.coreAPI.cmsSiteConfigAdd.Request_Api_Url,
                    method : 'POST',
                    data   : bodyParams
                },
                function (data) { 
    
                    cb();
                    
                }
            )
            
        }
    }

    F.Serial([
        isExistSetting,
        addOrUpdateSetting
    ],() => {
        RES.successResponse(res);
    })

}